﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文字过长的省略号</title>
    <script type="text/javascript"  language="JavaScript">
        let sText="这是一段很长的文本，希望通过省略号实现";
        let content;
        function OmitText(){
            content = "<nobr>" + sText + "</nobr>";
            document.getElementById("mydiv").innerHTML = content;
        }
        
    </script>
</head>
<body>

<input type=button value=加载 onclick="OmitText()">
<div STYLE="width: 150px; height: 50px; border: 1px solid black; 
            overflow: hidden; text-overflow:ellipsis" id="mydiv">
</div>

</body>
</html>